class NoteSqlMap(object):
    NOTE_LIST = "SELECT n.target,n.note_id,r.creat_time,r.update_time FROM kb_note n INNER JOIN kb_record r ON r.note_id=n.note_id WHERE n.user_id='{user_id}' and r.is_delete=false "
    
    ADD_NOTE = "INSERT INTO kb_note(`target`,`data_username`,`data_password`,`remarks`,`user_id`) " \
               "VALUES ('{target}','{data_username}','{data_password}','{remarks}','{user_id}');SELECT @@IDENTITY;"
    
    DEL_NOTE = "DELETE FROM kb_note WHERE note_id={note_id}"
    
    UPD_NOTE = "UPDATE kb_note SET target='{target}',data_username='{data_username}',data_password='{data_password}',remarks='{remarks}',user_id='{user_id}' where " \
               "note_id={note_id}"

    NOTE_INFO = "SELECT * FROM kb_note n INNER JOIN kb_record r ON r.note_id=n.note_id WHERE n.note_id='{note_id}'"

    NOTE_SYNC = "SELECT * FROM kb_note n INNER JOIN kb_record r ON r.note_id=n.note_id WHERE n.user_id='{user_id}' and r.creat_time<{sync_time} and r.delete_time<{sync_time} and r.update_time<{sync_time}"


class RecordSqlMap(object):
    ADD_RECORD = "INSERT INTO kb_record(record_id,creat_time,note_id,is_delete) VALUES ({record_id},'{creat_time}',{note_id},false )"
    
    # DEL_RECORD = ""
    
    DEL_NOTE_UPD_RECORD = "UPDATE kb_record SET delete_time='{delete_time}',is_delete=true"
    
    UPD_NOTE_UPD_RECORD = "UPDATE kb_record SET update_time='{update_time}' where note_id={note_id}"
